﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace BoardAlgorithm
{
    public enum Direction { Up = 0, Down =1, Right=2, Left =3}
    public enum BlockStatus { New, StartGot, EndGot, Blocked}

    public class BoardBlock
    {
        #region Properties
        public int PositionX { get; set; }
        public int PositionY { get; set; }

        public bool IsEnd { get; set; }
        public bool IsStart { get; set; }
        public BlockStatus Status { get; set; }

        public int TurnCount { get; set; }
        public int StepCount { get; set; }
        public BoardBlock PrevBlock { get; set; }

        #endregion

        public override string ToString()
        {
            return string.Format("Turn:{0}, Status:{1}"
                , TurnCount, Status.ToString());
        }

        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public BoardBlock(int x, int y)
        {
            PositionX = x;
            PositionY = y;

            IsEnd = false;
            IsStart = false;
            Status = BlockStatus.New;

            TurnCount = -1;
            StepCount = -1;

            PrevBlock = null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private static Direction getDirection(BoardPoint startPoint, BoardPoint endPoint)
        {
            if (startPoint.X == endPoint.X)
            {
                if (startPoint.Y > endPoint.Y)
                {
                    return Direction.Up;
                }
                else if(startPoint.Y < endPoint.Y)
                {
                    return Direction.Down;
                }
            }
            else if(startPoint.Y == endPoint.Y)
            {
                if (startPoint.X > endPoint.X)
                {
                    return Direction.Left;
                }
                else if (startPoint.X < endPoint.X)
                {
                    return Direction.Right;
                }
            }

            throw new Exception();
        }
    }
}
